<template>
  <div class="my">
      <header>
        <div class="bg" @click="goLogin">
          <img :src="loginStatus ? userInfo.imgUrl : './img/avatar.png'" alt="" />
          <p>{{ loginStatus ? userInfo.nick : '登录/注册' }}</p>
        </div>
        <div class="adress">
          <div class="adress-top">
            <p>我的订单</p>
            <p>
              全部订单
              <i class="iconfont icon-right"></i>
            </p>
          </div>
          <ul class="adress-bottom">
            <li>
              <img src="@/assets/img/fukuan.png" alt="" />
              <p>待付款</p>
            </li>
            <li>
              <img src="@/assets/img/shouhuo.png" alt="" />
              <p>待收货</p>
            </li>
            <li>
              <img src="@/assets/img/weixiu.png" alt="" />
              <p>退换修</p>
            </li>
          </ul>
        </div>
      </header>
      <section>
        <ul class="items">
          <li>
            <img src="../assets/img/huiyuan.png" alt="" />
            <div class="item-content">
              <p>会员中心</p>
              <div class="icon">
                <i class="iconfont icon-right"></i>
              </div>
            </div>
          </li>
          <li>
            <img src="../assets/img/youhui.png" alt="" />
            <div class="item-content">
              <p>我的优惠</p>
              <div class="icon">
                <i class="iconfont icon-right"></i>
              </div>
            </div>
          </li>
        </ul>
        <ul class="items">
          <li>
            <img src="../assets/img/fuwu.png" alt="" />
            <div class="item-content">
              <p>服务中心</p>
              <div class="icon">
                <i class="iconfont icon-right"></i>
              </div>
            </div>
          </li>
          <li>
            <img src="../assets/img/jia.png" alt="" />
            <div class="item-content">
              <p>小米之家</p>
              <div class="icon">
                <i class="iconfont icon-right"></i>
              </div>
            </div>
          </li>
        </ul>
        <ul class="items">
          <li>
            <img src="../assets/img/fma.png" alt="" />
            <div class="item-content">
              <p>我的F码</p>
              <div class="icon">
                <i class="iconfont icon-right"></i>
              </div>
            </div>
          </li>
          <li>
            <img src="../assets/img/liwu.png" alt="" />
            <div class="item-content">
              <p>礼物码兑换</p>
              <div class="icon">
                <i class="iconfont icon-right"></i>
              </div>
            </div>
          </li>
        </ul>
        <ul class="items last-items" @click="goLogout">
          <li>
            <img src="../assets/img/seting.png" alt="" />
            <div class="item-content">
              <p>设置</p>
              <div class="icon">
                <i class="iconfont icon-right"></i>
              </div>
            </div>
          </li>
        </ul>
      </section>
    <Tabbar />
  </div>
</template>

<script>
import { mapState } from 'vuex'
import Tabbar from '@/components/common/Tabbar'
export default {
  name: 'My',
  components: {
    Tabbar
  },
  computed: {
    ...mapState({
      userInfo: state => state.user.userInfo,
      loginStatus: state => state.user.loginStatus
    })
  },
  methods: {
    goLogin () {
      if (JSON.parse(localStorage.getItem('userInfo'))) return false
      this.$router.push('/login')
    },
    goLogout () {
      if (this.loginStatus) {
        this.$router.push('/setting')
        return false
      }
      this.$router.push('/login')
    }
  }
}
</script>

<style lang="scss" scoped>
.my {
  width: 100vw;
  height: 100vh;
  background-color: #eee;
  overflow: hidden;
  header {
    width: 100%;
    height: 5.68rem;
    background-color: #ff6700;
    .bg {
      width: 100%;
      height: 2.213333rem;
      background: url("../assets/img/bg.png") no-repeat 0 0;
      display: flex;
      align-items: center;
      padding-left: 0.8rem;
      img {
        width: 1.173333rem;
        height: 1.173333rem;
        border-radius: 50%;
      }
      p {
        font-size: 0.266667rem;
        color: #fff;
        margin-left: 0.266667rem;
      }
    }
    .adress {
      width: 100%;
      height: 3.466667rem;
      background-color: #fff;
      .adress-top {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        height: 1.12rem;
        padding: 0 0.266667rem;
        box-sizing: border-box;
        color: #333;
        font-size: 0.373333rem;
        text-align: center;
        border-bottom: 1px solid #eee;
      }
      .adress-bottom {
        display: flex;
        justify-content: space-around;
        align-items: center;
        height: 2.346667rem;
        text-align: center;
        li {
          display: flex;
          flex-direction: column;
          color: #333;
          font-size: 0.32rem;
          text-align: center;
          img {
            width: 0.8rem;
            height: 0.8rem;
            padding-left: 3px;
          }
        }
      }
    }
  }
  section {
    width: 100%;
    height: 390px;
    margin-top: 0.266667rem;
    .items {
      width: 100%;
      background-color: #fff;
      margin-bottom: 0.266667rem;
      box-sizing: border-box;
      li {
        display: flex;
        align-items: center;
        width: 100%;
        height: 1.386667rem;
        text-align: center;
        box-sizing: border-box;
        img {
          width: 0.72rem;
          height: 0.72rem;
          padding: 0 0.266667rem;
        }
        .item-content {
          display: flex;
          justify-content: space-between;
          border-bottom: 1px solid #eee;
          width: 100%;
          height: 1.386667rem;
          p {
            font-size: 0.426667rem;
            line-height: 1.386667rem;
            color: rgba(0, 0, 0, 0.87);
          }
          .icon {
            line-height: 1.386667rem;
            .icon-right {
              font-size: 0.48rem;
              color: rgba(0, 0, 0, 0.87);
            }
          }
        }
      }
    }
  }
}
</style>
